package org.admin.entity.dto;

import core.validate.Rule;
import lombok.Data;
import org.admin.entity.BaseDto;
import org.admin.entity.domain.Role;

import java.util.List;
import java.util.Objects;

@Data
public class RoleDto extends BaseDto<RoleDto> {
    protected RoleDto inst(){ return this; }
    public RoleDto(){
        addRule(new Rule[]{
                Rule.Number("id").min(0, "指定角色不存在"),
                Rule.String("name").between(1, 32, "角色名称长度不正确"),
                Rule.Boolean("upload").setMessages("参数不合法"),
                Rule.Array("ids").min(1, "未指定删除角色"),
                Rule.Number("current").min(1, "当前分页错误"),
                Rule.Number("size").onPreCheck(val -> Objects.requireNonNullElse(val, 20))
                        .min(1, "分页数量错误")
        });
    }
    private Integer id;
    private String name;
    private Boolean upload;
    private List<Integer> ids;
    private Integer current;
    private Integer size;
}
